import request from '../../../../../public/js/common/api/api.js';

const CBSUrl = Utils.CurDomain.CBSUrl;
const SysPlfUrl = Utils.CurDomain.SysPlfUrl;
const MasterDataUrl = Utils.CurDomain.MasterDataUrl;
const SysCfgUrl = Utils.CurDomain.SysCfgUrl;
const BaseCfgUrl = Utils.CurDomain.BaseCfgUrl
const AuthUrl = Utils.CurDomain.AuthUrl;

const _ajaxOptions = {
    contentType: 'application/json',
    dataType: 'text',
    async: true,
    dataFilter(data, type) {
        return data;
    }
};
export default class pigRepurchasesApi {
    // 选择批次获取其他信息
    static getbreedbatch(param) {
        return request.post(`${Utils.CurDomain.BaseCfgUrl}/breedbatchs/cur`, param);
    }

    // 获取养户信息
    static getfosterfarmers(param) {
        return request.get(`${Utils.CurDomain.CBSUrl}/fosterfarmers/by/q?SearchInfo=${param}&PageIndex=0&PageSize=10`);
    }

    /**
     * 获取当前用户拥有的组织
     * @param 
     * @returns 
     */
    static getOrgsList() {
        return request.get(`${AuthUrl}/accounts/orgs`);
    }

    /**
     * 查询批次存栏数
     * @param data
     * @returns 
     */
    static getBreedbatchsNum(id, pigType) {
        return request.get(`${BaseCfgUrl}/breedbatchs/num/${id}/${pigType}`);
    }
    /**
    * 根据业务日期査询批次存栏信息
    * @param ids
    * @returns
    */
    static postBreedbatchsNum(data) {
        return request.post(`${BaseCfgUrl}/breedbatchs/pigtypenum`, data, true);
    }
    /**
     * 查询猪只回购单Dt列表
     * @param data
     * @returns 
     */
    static postPigRepurchasesBillList(data) {
        return request.post(`${CBSUrl}/pigrepurchases/list`, data);
    }

    /**
     * 创建 猪只回购单
     * @param data
     * @returns 
     */
    static postPigRepurchases(data) {
        return request.post(`${CBSUrl}/pigrepurchases`, data, true, _ajaxOptions);
    }

    /**
     * 更新 猪只回购单
     * @param data
     * @returns 
     */
    static putPigRepurchases(id, data) {
        return request.put(`${CBSUrl}/pigrepurchases/${id}`, data, true, _ajaxOptions);
    }

    /**
     * 查询详情 猪只回购单
     * @param data
     * @returns
     */
    static getPigRepurchases(id) {
        return request.get(`${CBSUrl}/pigrepurchases/${id}`);
    }

    /**
     * 删除 猪只回购单
     * @param data
     * @returns 
     */
    static deletePigRepurchases(id) {
        return request.delete(`${CBSUrl}/pigrepurchases/${id}`);
    }

    /**
     * 提交 猪只回购单
     * @param ids
     * @returns 
     */
    static submitPigRepurchases(ids) {
        return request.put(`${CBSUrl}/pigrepurchases/submit/${ids.id}`, ids);
    }
    /**
     * 反提交 猪只回购单
     * @param ids
     * @returns 
     */
    static rollSubmitPigRepurchases(ids) {
        return request.put(`${CBSUrl}/pigrepurchases/resubmit/${ids.id}`, ids);
    }
    /**
     * 审核 猪只回购单
     * @param ids
     * @returns 
     */
    static auditPigRepurchases(ids) {
        return request.put(`${CBSUrl}/pigrepurchases/audit/${ids.id}`, ids);
    }
    /**
     * 反审核 猪只回购单
     * @param ids
     * @returns 
     */
    static rollPigRepurchases(ids) {
        return request.put(`${CBSUrl}/pigrepurchases/reaudit/${ids.id}`, ids);
    }

    /**
     * 获取财务组织
     * @param 
     * @returns 
     */
    static getOrgHrList(upoid, aotype) {
        return request.get(`${SysPlfUrl}/yyorgunits/by/q/fi`);
    }

    /**
     * 获取客户信息
     * @param data
     * @returns 
     */
    static getCustomerList() {
        return request.get(`${MasterDataUrl}/yycustomers/by/q`);
    }

    /**
     * 获取人员信息
     * @param data
     * @returns 
     */
    static getPersonList() {
        return request.get(`${MasterDataUrl}/yypersons/by/q`);
    }

    /**
     * 获取服务部信息
     * @param data
     * @returns 
     */
    static queryComDepList(upoid, aotype) {
        return request.get(`${SysPlfUrl}/yyorgunits/by/q?upoid=${upoid}&aotype=${aotype}`);
    }

    /**
     * 获取服务部信息
     * @param data
     * @returns 
     */
    static queryBaseOrgunitList(upoid, aotype, taginfo) {
        return request.get(`${SysPlfUrl}/yyorgunits/by/q?upoid=${upoid}&aotype=${aotype}&taginfo=${taginfo}`);
    }

    /**
     * 查询附件信息
     * @param ids
     * @returns 
     */
    static requestImagePath(id) {
        return request.get(`${SysCfgUrl}/yyattachments/${id}/url`);
    }

    /**
     * 查询养户关联的批次号
     * @param ids
     * @returns 
     */
    static getFosterfarmers(id) {
        return request.get(`${CBSUrl}/fosterfarmers/batch/${id}`);
    }
}